package com.foxzzz.contest83;

import java.util.ArrayList;
import java.util.List;

public class Solution1 {
    public List<List<Integer>> largeGroupPositions(String S) {
        int start=0;
        Character c=null;
        List<List<Integer>> list=new ArrayList<>();
        for (int i = 0; i <=S.length(); i++) {
            if(c==null||i==S.length()||S.charAt(i)!=c){
                if(i-start>=3){
                    ArrayList<Integer> arrayList=new ArrayList<>(2);
                    arrayList.add(start);
                    arrayList.add(i-1);
                    list.add(arrayList);
                }
                if(i==S.length())
                    break;
                start=i;
                c=S.charAt(i);
            }
        }
        return list;
    }

    public static void main(String[] args) {
        System.out.println(new Solution1().largeGroupPositions("aaa"));
    }
}
